﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using CTTest.Common;
using CTTest.Essential;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using CTTest.Essential.Soap.Shell;

namespace CTTest
{
    public partial class CTTestMain
    {
        [Obsolete("经过讨论，决定不模拟外部用户向FTP服务器发送联机工单请求。而且直接调用APE的BMS模拟工单请求。")]
        [TestMethod]
        [Description("测试阿网的联机工单接口！Obsolete")]
        public void 联机工单测试()
        {
            WriteLogger("Entering test method {0}", MethodBase.GetCurrentMethod().Name);

            const string req = @"c:\000.000";
            const string url = "ftp://192.168.31.31/usr/stvCtWorksheet";
            const string uid = "chenyunzhe";
            const string pwd = "111111";


            var s = FtpUtil.DisplayFileFromServer(url, uid, pwd);
            WriteLogger("FTP server {0} contains file list: {1}", url, s);

            FtpUtil.UploadFile(url, uid, pwd, req);
            WriteLogger("File {0} added to FTP server {1}", req, url);

            var q = FtpUtil.DisplayFileFromServer(url, uid, pwd);
            WriteLogger("FTP server {0} contains file list: {1}", url, q);

            WriteLogger("Leaving test method {0}", MethodBase.GetCurrentMethod().Name);
        }

        [TestMethod]
        [Description("测试阿网的CEP工单接口")]
        public void CEP工单测试()
        {
            WriteLogger("Entering test method {0}", MethodBase.GetCurrentMethod().Name);

            const string xml = @"c:\cep.xml";

            var data = File.ReadAllText(xml, Encoding.UTF8);
            CepUtil.TestShProvinceService(data, WriteLogger);

            WriteLogger("Leaving test method {0}", MethodBase.GetCurrentMethod().Name);
        }

        [TestMethod]
        [Description("测试阿网的PAI工单接口")]
        public void PAI工单测试()
        {
            WriteLogger("Entering test method {0}", MethodBase.GetCurrentMethod().Name);

            PaiUtil.TestChangeNumber(new ChangeNumberRequestVO(), WriteLogger);
            PaiUtil.TestChangeUserFeatures(new ChangeUserFeaturesRequestVO(), WriteLogger);
            PaiUtil.TestChangeUserState(new ChangeUserStateRequestVO(), WriteLogger);
            PaiUtil.TestCreateUser(new CreateUserRequestVO(), WriteLogger);
            PaiUtil.TestDeleteUser(new DeleteUserRequestVO(), WriteLogger);

            WriteLogger("Leaving test method {0}", MethodBase.GetCurrentMethod().Name);
        }
    }
}
